<?php
	$file = "f:\admin_crm.sql";

	$conn = mysql_connect('localhost','root','');
	mysql_select_db('admin_crm');
	mysql_query("set names 'utf8'");

	function input_phpadmin($file){
		if(!is_file($file)){return false;}
		$f = fopen($file,'r');
		$sql = '';
		while(!feof($f)){
			$str = fgets($f);
			if(strpos($str,'INSERT INTO') !== false || strpos($str,'DROP') !== false || strpos($str,'CREATE TABLE') !== false){
				$sql .= $str;
				if(strpos($str,';') !== false){
					mysql_query($sql);
					$sql = '';
				}
			}else if(!empty($sql)){
				$sql .= $str;
				if(strpos($str,';') !== false){
					mysql_query($sql);
					$sql = '';
				}
			}
		}
	}

	input_phpadmin('./crm_agent.sql');
	input_phpadmin('./crm_salesperson.sql');
	input_phpadmin('./crm_salesperson_groups.sql');
	input_phpadmin('./crmv2_student.sql');
	input_phpadmin('./program_student_course.sql');
	input_phpadmin('./project_course_info.sql');
	input_phpadmin('./student_payment_record.sql');
	mysql_close($conn);
?>